Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python-package] limit when num_boost_round warnings are emitted (fixes #6324) #6579

Merged
merged 17 commits into from
Sep 3, 2024

Conversation

jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Jul 30, 2024

Fixes #6324

Replaces #6548

  • ensures that the warning about aliases for num_iterations is only raised if the user-provided configuration has conflicting values
  • expands documentation about how parameters in LightGBM are merged

Notes for Reviewers

Just opening this to show I'm working on it. It still needs tests, and isn't ready for review yet.

How I tested this

Enabled this branch on readthedocs. See https://readthedocs.org/projects/lightgbm/builds/.

Isn't this kind of a lot of complexity for one parameter?

I think it's worth it. "number of boosting rounds" is one of the most important parameters for gradient boosting. I think it's worth handling it very carefully and raising an informative warning in the cases where conflicting configuration is provided. For example, I think this warning could save people from unnecessarily performing hyperparameter tuning over different combinations of num_iterations and num_trees, not understanding that those mean the same thing in LightGBM's parameters.

Why not use pytest.parametrize() for all these tests?

I started out that way, but then decided that it'd require enough if-else blocks and other logic that I was worried about accidentally, silently, mishandling some test cases.

I think the level of repetition in these test cases is ok, because it makes them easy to read and understand.

@jameslamb jameslamb changed the title WIP: [python-package] limit when num_boost_round warnings are emitted (fixes #6324) [python-package] limit when num_boost_round warnings are emitted (fixes #6324) Aug 2, 2024
@jameslamb jameslamb marked this pull request as ready for review August 2, 2024 18:06
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the general idea of this PR!
Left some minor comments below:

docs/Parameters.rst Outdated Show resolved Hide resolved
docs/Parameters.rst Outdated Show resolved Hide resolved
python-package/lightgbm/engine.py Show resolved Hide resolved
python-package/lightgbm/engine.py Show resolved Hide resolved
python-package/lightgbm/engine.py Show resolved Hide resolved
tests/python_package_test/test_sklearn.py Show resolved Hide resolved
tests/python_package_test/utils.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for addressing my comments!
I have two more suggestions based on the most recent commit.

docs/Parameters.rst Outdated Show resolved Hide resolved
python-package/lightgbm/engine.py Show resolved Hide resolved
tests/python_package_test/test_sklearn.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for working on this change!

@jameslamb jameslamb merged commit 3ccdea1 into master Sep 3, 2024
44 checks passed
@jameslamb jameslamb deleted the python/alias-warning branch September 3, 2024 03:46
@jameslamb
Copy link
Collaborator Author

Thanks for the thoughtful reviews @StrikerRUS !

@StrikerRUS
Copy link
Collaborator

@jameslamb Could you please remove python/alias-warning branch on RTD?

I think we don't need to leave debug builds there.

image

@jameslamb
Copy link
Collaborator Author

🙈 sorry about that, thanks for your attention to detail!

Just removed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[python-package] UserWarning: Found ... in params
2 participants